package com.longcai.controller;


import com.longcai.bean.PageHelper;
import com.longcai.entity.sys.SysLog;
import com.longcai.page.table.PageTableResponse;
import com.longcai.service.SysLogService;
import com.longcai.util.aspect.Log;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 系统日志 前端控制器
 * </p>
 *
 * @author LWK
 * @since 2019-04-02
 */
@RestController
@RequestMapping("/sysLog")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    @ApiOperation(value = "保存日志")
    @GetMapping(value = "/save")
    public Integer save(SysLog sysLog) throws Exception {
        return this.sysLogService.save(sysLog);

    }

    @ApiOperation(value = "查询日志")
    @GetMapping(value = "/findById")
    public SysLog selectById(String userId) throws Exception {
        System.out.println(userId);
        return this.sysLogService.selectById(userId);
    }

    @ApiOperation(value = "用户日志分页列表")
    @GetMapping(value = "/sysLogList")
    @Log("查询日志")
    public PageTableResponse sysLogList(SysLog sysLog, PageHelper pageHelper) {
        System.out.println(sysLog);
        return this.sysLogService.sysLogListPage(sysLog, pageHelper);
    }

    /**
     * @param userId
     */
    @PostMapping("{userId}")
    public void delSysLog(@PathVariable String userId) {
        this.sysLogService.delSysLog(userId);
    }
}



